package com.class05.ioc02;


import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
//@Scope("prototype")
// 相当于 <bean id ="..."  class="..." scope="prototype"/>
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)  //配置组件为多例
public class JavaBean {

//    周期方法命名随意  必须：是public 没有参数 没有返回值（void）

//    @PostConstruct   相当于 <bean init-method="init"/>
    @PostConstruct
    public void init() {
        System.out.println("init");
    }

//    @PreDestroy    相当于 <bean destroy-method="destroy"/>
    @PreDestroy
    public void destroy() {
        System.out.println("destroy");
    }
}
